sentinel_3_cube =Cube(open_dataset("/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/OLCI_Sentinel3_gridded_1km_europe_2018-01-04_2020-12-29.zarr/"))sentinel_3_cube.Variable## selecting only OTCI and 2018-07otci_cube_high = sentinel_3_cube[Variable =At("OGVI"), Ti =Between(DateTime("2018-07-01"),DateTime("2018-07-31"))]
4800×4800×4 YAXArray{Float32,3} with dimensions: X Sampled{Int64} 1:1:4800 ForwardOrdered Regular Points,
Y Sampled{Int64} 1:1:4800 ForwardOrdered Regular Points,
Ti Sampled{DateTime} DateTime[2018-07-06T00:00:00, …, 2018-07-30T00:00:00] ForwardOrdered Irregular Points
Total size: 351.56 MB
Collapsing time dimension. As data for each one of the product has a different length, and interpolation with 4 points is risky let’s estimate the mean for the month of july
┌ Warning: There are still cache misses
└ @ YAXArrays.DAT /Net/Groups/BGI/people/dpabon/bin/julia_packages/packages/YAXArrays/no0he/src/DAT/DAT.jl:1076
sif_cube_low_july =Cube(open_dataset("/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/sif_cube_low_july.zarr"))# let's match X and Y in the other cubesaxlist = (Dim{:X}(1:480),Dim{:Y}(1:480))sif_cube_low_july =YAXArray(axlist, sif_cube_low_july.data[:,:])lst_cube_high_july =Cube(open_dataset("/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/lst_cube_high_july.zarr"))otci_cube_high_july =Cube(open_dataset("/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/otci_cube_high_july.zarr"))ndwi_cube_high_july =Cube(open_dataset("/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/ndwi_cube_high_july.zarr"))
4800×4800 YAXArray{Union{Missing, Float32},2} with dimensions: X Sampled{Int64} 1:1:4800 ForwardOrdered Regular Points,
Y Sampled{Int64} 1:1:4800 ForwardOrdered Regular Points
name: NDWI
Total size: 87.89 MB
# checking that we have at least min_obs data points for each variable in the local window
if !all(isnan, sif) && !all(isnan, vegetation) && !all(isnan, water) && !all(isnan, temperature)
if length(filter(!isnan, vec(sif))) >= min_obs && length(filter(!isnan, vec(vegetation))) >= min_obs && length(filter(!isnan, vec(water))) >= min_obs && length(filter(!isnan, vec(temperature))) >= min_obs
if length(filter(!isnan, vec(sif))) == length(filter(!isnan, vec(vegetation))) && length(filter(!isnan, vec(sif)))== length(filter(!isnan, vec(water))) && length(filter(!isnan, vec(sif))) == length(filter(!isnan, vec(temperature)))
vi = filter(!isnan, vec(vegetation))
agua = filter(!isnan, vec(water))
lst = filter(!isnan, vec(temperature))
sif_ob = filter(!isnan, vec(sif))
test = optimize(b -> costfun(b, vi, agua, lst, sif_ob), param_min, param_max, param_ini, Fminbox(inner_optimizer))
out .= Optim.minimizer(test)
else
out .= NaN32
end
else
out .= NaN32
end
else
out .= NaN32
end
end
moving window
window_edge = 25
cambiar a mayor window size!!!
if isodd(window_edge) pre_step = after_step = floor(window_edge / 2) else pre_step = after_step = floor(window_edge / 2) - 1 end
heatmap(parameters_cube_high.data[:,:,1]) #= savecube(parameters_cube_high, “/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/parameters_cube_high_OGVI.zarr/”) =# #= parameters_cube_high = Cube(open_dataset(“/Net/Groups/BGI/work_3/OEMC/oemc_sif/data/parameters_cube_high.zarr/”)) =# # function to estimate sif using high resolution data
function sif_downscaling(out, vegetation, water, temperature, parameters)
if !all(isnan, vegetation) && !all(isnan, water) && !all(isnan, temperature) && !all(isnan, parameters)
if length(filter(!isnan, vec(vegetation)))== length(filter(!isnan, vec(water))) && length(filter(!isnan, vec(vegetation))) == length(filter(!isnan, vec(temperature)))
b_optim = [mean(parameters[:,:,1]),
mean(parameters[:,:,2]),
mean(parameters[:,:,3]),
mean(parameters[:,:,4]),
mean(parameters[:,:,5]),
mean(parameters[:,:,6])]
length(b_optim)
out .= sif(mean(filter(!isnan, vegetation)), mean(filter(!isnan, water)), mean(filter(!isnan, temperature)), b_optim)
else
out .= NaN32
end
else
out .= NaN32
end
end
using another moving window of 3x3 to Downscale SIF
window_edge = 3
if isodd(window_edge) pre_step = after_step = floor(window_edge / 2) else pre_step = after_step = floor(window_edge / 2) - 1 end